package cn.edu.neu.softlab633.influencemaximization.sy.bean;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by Jason on 2017/5/11.
 */
public class MarginGain implements Comparable<MarginGain> {
    private int marginGainNum;
    private Set<Integer> marginGainNode;

    public MarginGain() {
    }

    public MarginGain(int marginGainNum, Set<Integer> marginGainNode) {
        this.marginGainNum = marginGainNum;
        this.marginGainNode = marginGainNode;
    }

    public void setMarginGainNum(int marginGainNum) {
        this.marginGainNum = marginGainNum;
    }

    public void setMarginGainNode(Set<Integer> marginGainNode) {
        this.marginGainNode = marginGainNode;
    }

    public int getMarginGainNum() {

        return marginGainNum;
    }

    public Set<Integer> getMarginGainNode() {
        return marginGainNode;
    }

    @Override
    public int compareTo(MarginGain o) {
        if (this.getMarginGainNum() > o.getMarginGainNum()) {
            return 1;
        }
        if (this.getMarginGainNum() < o.getMarginGainNum()) {
            return -1;
        }
        return 0;
    }

    public MarginGain sub(MarginGain other) {
        Set<Integer> tmp = new HashSet<>();
        tmp.addAll(this.getMarginGainNode());
        tmp.removeAll(other.getMarginGainNode());
        return new MarginGain(tmp.size(), tmp);
    }

    public MarginGain add(MarginGain other) {
        Set<Integer> tmp = new HashSet<>();
        tmp.addAll(this.getMarginGainNode());
        tmp.addAll(other.getMarginGainNode());
        return new MarginGain(tmp.size(), tmp);
    }

}
